﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data;
using System.Runtime.Serialization;

namespace MyClever.Lib
{
    [Serializable()]
    public class MissionPluginPackageSet : DataSet, ISerializable
    {
        public MissionPluginPackageSet() 
            : base()
        {
        }

        // The special constructor is used to deserialize values. 
        public MissionPluginPackageSet(SerializationInfo info, StreamingContext context)
        {
            ArrayList packageDefinitions = (ArrayList)info.GetValue("PackageDefinitions", typeof(ArrayList));

            foreach (PackageDefinition packageDefinitionOn in packageDefinitions)
            {
                this.Tables.Add(new MissionPluginPackage(packageDefinitionOn));                
            }
        }

        // Implement this method to serialize data. The method is called on serialization. 
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            ArrayList packageDefinitions = new ArrayList();
            foreach (MissionPluginPackage packageOn in this.Tables)
            {
                packageDefinitions.Add(packageOn.GetDefinition());
            }

            info.AddValue("PackageDefinitions", packageDefinitions);
        }
    }
}
